<template>
  <swiper>
    <swiper-item v-for="item in bannerList" :key="item.image">
      <img :src="item.image" :alt="item.title" @load="imageLoad">
    </swiper-item>
  </swiper>
</template>

<script>
  import {Swiper, SwiperItem} from "components/common/swiper";

  export default {
    name: "HomeSwiper",
    components:{
      Swiper,
      SwiperItem
    },
    props: {
      bannerList: {
        type: Array,
        default(){
          return []
        }
      }
    },
    data(){
      return {
        isLoad: false,
      }
    },
    methods: {
      imageLoad(){
        // 只需要一个图片加载完就通知获取高度，不需要多次通知
        if (!this.isLoad) {
          this.isLoad = true
          this.$emit('swiperImageLoad')
        }
      }
    }
  }
</script>

<style scoped>

</style>
